<script lang="ts" setup>
import { ref } from 'vue';
import { userService } from '@/service';

const pageNum = ref(1);
const pageSize = ref(10);
const dataTotal = ref(0);
const dataRows = ref<Record<string, any>[]>([]);
const loading = ref(false);

// 初始加载
queryRechargeRecordPage();

async function queryRechargeRecordPage() {
  loading.value = true;
  const params = {
    pageSize: pageSize.value,
    pageNum: pageNum.value,
    transactionType: 1
  };
  const res = await userService.queryUserTransactionPage(params);
  if (res.success) {
    dataTotal.value = res.total;
    dataRows.value = res.result;
  }
  loading.value = false;
}

</script>


<template>
  <div class="page-recharge-record">
    <el-container class="table-container">
      <el-main class="page-body">
        <el-table :data="dataRows">
          <el-table-column prop="transactionPrice" label="充值金额" width="180" >
            <template #default="scope">
              {{scope.row.transactionPrice / 1000}} 元
            </template>
          </el-table-column>
          <el-table-column prop="transactionPrice" label="获得码豆" width="300" >
            <template #default="scope">
              {{scope.row.transactionPrice}} 码豆
            </template>
          </el-table-column>
          <el-table-column prop="createdAt" label="充值时间"  show-overflow-tooltip/>
        </el-table>
        <div class="table-pagination">
          <el-pagination
            :currentPage="pageNum"
            :pageSize="pageSize"
            background
            layout="total, prev, pager, next"
            :total="dataTotal"
            @currentChange="(val: number) => $emit('pageChange', val)"
          />
        </div>
      </el-main>
    </el-container>
  </div>
</template>

<style scoped lang="less">
.page-recharge-record{
  border-radius: 16px;
  background-color: var(--el-bg-color-overlay);
}
</style>
